
  class JsonHash < DataMapper::Type
    primitive String

    def self.dump(value, property)
      (value || {}).to_json
    end

    def self.load(value, property)
      if value.is_a? String
        JSON.parse(value)
       else
        value
      end
    end

    def self.typecast(value, property)
      value
    end
  end


  class JsonArray < DataMapper::Type
    primitive String

    def self.dump(value, property)
      (value || []).to_json
    end

    def self.load(value, property)
      JSON.parse(value)
    end

    def self.typecast(value, property)
      value
    end
  end

